package com.ygk.bluepath.notification.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.ygk.bluepath.core.BPresenterFragment;
import com.ygk.bluepath.core.BPresenter;

import utils.LogUtils;

/**
 * @author  李文伟 E-mail: handreace@163.com
 * @date 创建时间：2016年6月30日 下午5:03:15
 * @version 1.0
 */
public class GpsReceiver extends BroadcastReceiver {

	private BPresenter presenter;
	private BPresenterFragment fragmentPresenter;
	public GpsReceiver(BPresenterFragment presenter){
		this.fragmentPresenter=presenter;
	}
	public GpsReceiver(BPresenter presenter){
		this.presenter=presenter;
	}

	@Override
	public void onReceive(Context context, Intent intent) {
		{
			// 重写onReceive方法

			Bundle bundledata = intent.getExtras();
			if (bundledata != null) {
				double latitude = bundledata.getDouble("latitude");
				double longitude = bundledata.getDouble("longitude");

				String accuracy = bundledata.getString("accuracy");
				float speed = bundledata.getFloat("speed");
				// String Satenum = bundledata.getString("Satenum");
				String dateString = bundledata.getString("date");

				if (presenter!=null)
				presenter.LBSResult(longitude,latitude);
				else
				fragmentPresenter.LBSResult(longitude,latitude);
				//lbBean.setSpeed(speed);
				LogUtils.i("\n手机自带GPS定位结果：" + "\n\t经度:" + longitude + "\n\t纬度:" + latitude + "\n\t精度:" + accuracy
						+ "\n\t速度:" + speed + "m/s" + "\n\t更新时间:" + dateString);
			}

		}

	}

}
